<link href="//datatables.net/download/build/nightly/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script src="//datatables.net/download/build/nightly/jquery.dataTables.js"></script>
<script>

$(document).ready( function () {
  var table = $('#table_id').DataTable();
} );

	
</script>
<div class="tableData">
	<?php
	echo $this->Html->link("ADD", array (
								'controller' => 'categories', 
								'action' => 'update'
								)
					);
	?>
<table id="table_id">
    <thead>
        <tr>
            <th>Category Name</th>
            <th>Status</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    	<?php
    		foreach( $categories as $category ) 
			{
        		echo "<tr>";
        		echo "<td>" . $category['Category']['name'] . "</td>";
        		echo "<td>" . ( $category['Category']['status'] == 'A' ? 'Active' : 'Inactive' ) . "</td>";
				echo '<td>';
				echo $this->Html->link("<i class='icon-pen-note'></i>", 
										array(
											'controller' => 'categories', 
											'action' => 'update',
											$category['Category']['id']
											),
										array(
											'class' => 'btn formToggle', 
											'title' => 'Edit Data',
											'escape' => FALSE
											)
										);
				echo '&nbsp;';
				if ( $category['Organization']['id'] != 0 ) {

					echo $this->Html->link("<i class='icon-x'></i>", 
											array(
												'controller' => 'categories', 
												'action' => 'update',
												$category['Category']['id'],
												'D'
												),
											array(
												'class' => 'btn', 
												'title' => 'Delete',
												'escape' => FALSE
												)
											);
					
				}
				echo '</td>';
        		echo "</tr>";
			} ?>
    </tbody>
</table>
</div>